@echo off
set INDIR=..\pics
set OUTDIR=..\pics\output
echo.

:checkArgs
if "%1" == "" echo Invalid arguments & echo Usage: %0% ^<input_file^> ^{^<more_files^>^} & exit
goto createDirectory

:createDirectory
if not exist %OUTDIR% mkdir %OUTDIR% & goto processImages
goto processImages

:processImages
if "%1" == "" (goto finish)
if not exist %INDIR%\%1 echo Input File %1 does not exist! & echo Continue with next file. & shift & goto processImages
goto processSingleImg

:processSingleImg
if exist %OUTDIR%\wahet-%1-bmask.jpg echo File wahet-%1-bmask.jpg already exists! & echo Continue with next file. & shift &  goto processImages
if exist %OUTDIR%\caht-%1-bmask.jpg echo File caht-%1-bmask.jpg already exists! & echo Continue with next file. & shift &  goto processImages
wahet -i %INDIR%\%1 -bm %OUTDIR%\wahet-%1-bmask.jpg -o %OUTDIR%\wahet-%1-tex.jpg -e -lt 1
caht -i %INDIR%\%1 -bm %OUTDIR%\caht-%1-bmask.jpg -o %OUTDIR%\caht-%1-tex.png -e
shift
goto processImages

:finish
echo.